pkgname=3proxy
pkgver=0.6.1
pkgrel=1
pkgdesc="A tiny crossplatform proxy server"
arch=(i686 x86_64 cygwin)
url="http://www.3proxy.ru/"
license=('BSD')
depends=()
source=("http://www.3proxy.ru/$pkgver/3proxy-$pkgver.tgz"
        cygwin.patch)
md5sums=('03790467a12e16ed8785ae688ecf9b68'
         'bcfd75484bf28424ac1e7b7fa9ddaa62')

_cygwin_groups=('Net')
_cygwin_lpkgdesc="3Proxy tiny free proxy server is really tiny cross-platform (Win32/Win64&Unix)
freeware proxy servers set. It includes HTTP proxy with HTTPS and FTP support,
SOCKSv4/SOCKSv4.5/SOCKSv5 proxy (socks/socks.exe), POP3 proxy, SMTP proxy,
AIM/ICQ proxy (icqpr/icqpr.exe), MSN messenger / Live messenger proxy
(msnpr/msnpr.exe), FTP proxy, caching DNS proxy, TCP and UDP portmappers."

_prefix=/usr
_etcdir=/etc/3proxy
build() {
  cd "$srcdir/3proxy-$pkgver"
  cp src/proxy.h src/proxy.h~ && sed s/__CYGWIN__/__OLDCYGWIN__/g src/proxy.h~ > src/proxy.h || return 1
  cp Makefile.Linux Makefile.Linux~ && sed 's/^\(CFLAGS =\)/\1 -Werror-implicit-function-declaration /' Makefile.Linux~ > Makefile.Linux || return 1
  if [ "$pkg_arch" = "cygwin" ]; then
    sed -i 's/^\(CFLAGS =.*\)-DGETHOSTBYNAME_R/\1/' Makefile.Linux
  fi
  patch -p1 -i ../cygwin.patch
  make='make -f Makefile.Linux INSTALL=/bin/install'
  $make prefix="$_prefix" ETCDIR="$_etcdir"
  $make prefix="$_prefix" install DESTDIR="$pkgdir" ETCDIR="${pkgdir}${_etcdir}"
  ( cd ${pkgdir}${_prefix}/bin && mv proxy 3proxy-proxy ) || return 1
  install -D -m644 copying ${pkgdir}${_prefix}/share/licenses/$pkgname/copying
}

